<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<link href="css/style.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="artDialog/skins/default.css"
	type="text/css"></link>
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="artDialog/artDialog.min.js"></script>
<script type="text/javascript" src="artDialog/jquery.artDialog.min.js"></script>
<script type="text/javascript" src="artDialog/artDialog.plugins.min.js"></script>
<script type="text/javascript" src="js/util.js"></script>
<style>
#person_td input,#person_info_tb input {
	background-color: #EEEEEE
}
</style>
<script type="text/javascript">
	$.post("user!findCurrentUser.action", function(data) {
		var user = eval("(" + data + ")");
		$("#current_user_name").html(user.name);
		$("#current_user_email").html((user.email=="" ? "暂无邮箱":user.email));
		if(user.lastLoginDate==""){
			$("#person_login_time").html("暂无记录");
		}else{
			$("#person_login_time").html(user.lastLoginDate);
		}
		if(user.lastLoginIp==""){
			$("#person_login_ip").html("暂无记录");
		}else{
			$("#person_login_ip").html(user.lastLoginIp);
		}
	});
	function person_update_info() {
		$
				.post(
						"user!findCurrentUser.action",
						function(data) {
							var user = eval("(" + data + ")");
							art
									.dialog({
										title : '修改个人资料',
										content : '<ul class="forminfo"><li><label>姓名：<b>*</b></label><td><input type="text" id="person_name" class="dfinput" value="'+user.name+'" /></li><li><label>年龄：<b>*</b></label><input id="person_age" type="text" value="'+user.age+'" class="dfinput"  /></li><li><label>电话：<b>*</b></label><input id="person_phone" type="text" value="'+user.phone+'" class="dfinput" /></li><li><label>邮箱 ：<b>*</b></label><input id="person_email" type="text" value="'+user.email+'" class="dfinput" /></li></ul><p align="center"><span id="person_info_show" colspan="2" align="center" style="color:red"></span></p>',
										lock : true,
										fixed : true,
										ok : function() {
											var name = document.getElementById('person_name');
											var age = document.getElementById('person_age');
											var email = document.getElementById('person_email');
											var phone =document.getElementById('person_phone');
											if(name.value==""){
												$("#person_info_show").html("姓名不能为空");
												name.select();
												name.focus();
												this.shake();
												return false;
											}
											if(age.value==""){
												$("#person_info_show").html("年龄不能为空");
												age.select();
												age.focus();
												this.shake();
												return false;
											}else if(!/^[1-9]\d*$/.test(age.value)){
												$("#person_info_show").html("请输入正整数的年龄");
												age.select();
												age.focus();
												this.shake();
												return false;
											}
											if(phone.value!=""){
												if(!/^(13|15|17|18)\d{9}$/.test(phone.value)){
													$("#person_info_show").html("请输入以13，15，17，18开头的11位数字");
													phone.select();
													phone.focus();
													this.shake();
													return false;
												}
											}
											if(email.value!=""){
												if(!/^\w+@\w+(\.[a-zA-Z]{2,3}){1,2}$/.test(email.value)){
													$("#person_info_show").html("邮件格式不正确<br/>例:web@www.com或web@www.com.cn");
													email.select();
													email.focus();
													this.shake();
													return false;
												}
											}
											$.post("user!updatePersonInfo.action",{"user.name":name.value,"user.phone":phone.value,"user.email":email.value,"user.age":age.value},function(data){
												var json = eval("(" + data + ")");
												if (json.code == 1) {
													window.parent.frames.location.href="main.html";
												} else {
													defaultAlert("修改资料", "修改失败");
												}
											});
										},
										okValue : '修改',
										cancelValue : '取消',
										cancel : function() {
										}
									});
						});

	}
	function person_update_password() {
		art
				.dialog({
					id : 'shake-demo',
					title : '修改密码',
					content : '<ul class="forminfo"><li><label>原密码：<b>*</b></label><input class="dfinput" type="password" id="person_old_pwd" value="" /></li><li><label>新密码：<b>*</b></label><input id="person_new_pwd" type="password" class="dfinput" /></li><li><label>确认新密码：<b>*</b></label><input id="person_new_repwd" type="password" class="dfinput" /></li></ul><p align="center"><span id="person_show" colspan="2" align="center" style="color:red"></span></p>',
					lock : true,
					fixed : true,
					ok : function() {
						var opw = document.getElementById('person_old_pwd');
						var pw = document.getElementById('person_new_pwd');
						var repw = document.getElementById('person_new_repwd');
						if (opw.value == "") {
							$("#person_show").html("旧密码不能为空");
							opw.select();
							opw.focus();
							this.shake();
							return false;
						}
						if (pw.value == "") {
							$("#person_show").html("新密码不能为空");
							pw.select();
							pw.focus();
							this.shake();
							return false;
						}
						if (repw.value == "") {
							$("#person_show").html("确认新密码不能为空");
							repw.select();
							repw.focus();
							this.shake();
							return false;
						}
						if (pw.value != repw.value) {
							$("#person_show").html("两次密码输入不一致");
							repw.select();
							repw.focus();
							this.shake();
							return false;

						}
						$.post("user!updatePassword.action", {
							"oldPwd" : opw.value,
							"newPwd" : repw.value
						}, function(data) {
							var json = eval("(" + data + ")");
							if (json.code == 1) {
								callbackAlert("修改密码", "修改成功", function() {
									user_loginout();
								});
							} else {
								defaultAlert("修改密码", "修改失败");
							}
						});
					},
					okValue : '修改',
					cancelValue : '取消',
					cancel : function() {
					}
				});
	}
</script>
</head>


<body>

	<div class="place">
		<span>位置：</span>
		<ul class="placeul">
			<li><a href="#">首页</a>
			</li>
		</ul>
	</div>

	<div class="mainindex">


		<div class="welinfo">
			<span><img src="images/sun.png" alt="天气" />
			</span> <b><label id="current_user_name"></label>，欢迎使用电力巡检系统</b>(<label
				id="current_user_email"></label>) <a href="javascript:void(0)"
				onclick="person_update_info()">修改资料</a>
		</div>

		<div class="welinfo">
			<span><img src="images/time.png" alt="时间" />
			</span> <i>您上次登录的时间：<label id="person_login_time"></label>&nbsp;&nbsp;&nbsp;<!-- 您上次登录的IP地址：<label
				id="person_login_ip"></label> -->
			</i> （不是您登录的？<a href="javascript:void(0)"
				onclick="person_update_password()">修改密码</a>）
		</div>

		<!-- <div class="xline"></div>

		<ul class="iconlist">

			<li><img src="images/ico01.png" />
			<p>
					<a href="#">管理设置</a>
				</p>
			</li>
			<li><img src="images/ico02.png" />
			<p>
					<a href="#">发布文章</a>
				</p>
			</li>
			<li><img src="images/ico03.png" />
			<p>
					<a href="#">数据统计</a>
				</p>
			</li>
			<li><img src="images/ico04.png" />
			<p>
					<a href="#">文件上传</a>
				</p>
			</li>
			<li><img src="images/ico05.png" />
			<p>
					<a href="#">目录管理</a>
				</p>
			</li>
			<li><img src="images/ico06.png" />
			<p>
					<a href="#">查询</a>
				</p>
			</li>

		</ul>

		<div class="ibox">
			<a class="ibtn"><img src="images/iadd.png" />添加新的快捷功能</a>
		</div>

		<div class="xline"></div>
		<div class="box"></div>

		<div class="welinfo">
			<span><img src="images/dp.png" alt="提醒" />
			</span> <b>Uimaker信息管理系统使用指南</b>
		</div>

		<ul class="infolist">
			<li><span>您可以快速进行文章发布管理操作</span><a class="ibtn">发布或管理文章</a>
			</li>
			<li><span>您可以快速发布产品</span><a class="ibtn">发布或管理产品</a>
			</li>
			<li><span>您可以进行密码修改、账户设置等操作</span><a class="ibtn">账户管理</a>
			</li>
		</ul>

		<div class="xline"></div>

		<div class="uimakerinfo">
			<b>查看Uimaker网站使用指南，您可以了解到多种风格的B/S后台管理界面,软件界面设计，图标设计，手机界面等相关信息</b>(<a
				href="http://www.uimaker.com" target="_blank">www.uimaker.com</a>)
		</div>

		<ul class="umlist">
			<li><a href="#">如何发布文章</a>
			</li>
			<li><a href="#">如何访问网站</a>
			</li>
			<li><a href="#">如何管理广告</a>
			</li>
			<li><a href="#">后台用户设置(权限)</a>
			</li>
			<li><a href="#">系统设置</a>
			</li>
		</ul>


	</div>
 -->
</body>
</html>
